package com.notes.designpattern.chain;


import com.notes.designpattern.chain.domain.BaseResp;
import com.notes.designpattern.chain.domain.BusinOneBO;
import com.notes.designpattern.chain.domain.BusinOneReq;
import com.notes.designpattern.chain.handler.BusinOneHandler;
import com.notes.designpattern.chain.handler.BusinThreeHandler;
import com.notes.designpattern.chain.handler.BusinTwoHandler;

/**
 * @author
 * @Describe 功能描述
 * @date
 */
public class ChainTest {

    public static void main(String[] args) {
        BusinHandlerChain businHandlerChain = new BusinHandlerChain();
        businHandlerChain.addBusinHandler(new BusinOneHandler("BusinOneHandler"));
        businHandlerChain.addBusinHandler(new BusinTwoHandler("BusinTwoHandler"));
        businHandlerChain.addBusinHandler(new BusinThreeHandler("BusinThreeHandler"));

        BusinOneReq businOneReq = new BusinOneReq();
        businOneReq.setBusinKey("BusinOneHandler");
        BaseResp processResp = businHandlerChain.process(businOneReq, new BusinOneBO(), businHandlerChain);

        if (processResp.getErrorNo() == 0) {
            System.out.println("业务最终处理结果：成功");
        } else {
            System.out.println("业务最终处理结果：失败");
        }
    }
}
